Nullable.getValueOr

Gets the value or the default value passed in.

struct Nullable(T)
ref inout
inout(T)
getValueOr
(
lazy inout T defVal
)

Return Value

Type: inout(T)

The value held internally by this Nullable or the extra value passed in.

Examples

import std.exception: assertThrown, assertNotThrown;

Nullable!int ni;
//`get` is implicitly called. Will throw
//an AssertError in non-release mode
assertThrown!Throwable(ni += 1);

ni = 0;
assertNotThrown!Throwable(ni += 1);

Meta